<?php
App::uses('AppModel', 'Model');
/**
 * AsoCitasObservadore Model
 *
 * @property Cita $Cita
 * @property Observador $Observador
 */
class AsoCitaObservador extends AppModel {

	/**
	 * Use database config
	 *
	 * @var string
	 */
	public $useDbConfig = 'default';

	/**
	 * Use table
	 *
	 * @var mixed False or table name
	 */
	public $useTable = 'aso_cita_observador';

	//The Associations below have been created with all possible keys, those that are not needed can be removed

	/**
	 * belongsTo associations
	 *
	 * @var array
	 */
	public $belongsTo = array(
		'Cita' => array(
			'className' => 'Cita',
			'foreignKey' => 'cita_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Observador' => array(
			'className' => 'Observador',
			'foreignKey' => 'observador_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
	
	/*
	 * Funciones
	 */
	
	public function obtenerObservadoresPorCita($cita_id) {
		
		$observadores = $this -> find(
			'all', 
			array(
				'conditions'=>array('AsoCitaObservador.cita_id'=>$cita_id),
				'fields'=>array('Observador.nombre', 'Observador.codigo', 'Observador.id')
			)
		);
		
		return $observadores;
	}
}
